//操作用户cookie的工具类

//使用js-cookiejs类库
import Cookie from "js-cookie"

export default {
    //保存用户数据
    setUser(user) {
        Cookie.set("Cookie-Name",user.name)
        Cookie.set("Cookie-Token",user.token)
        Cookie.set("Cookie-Avatar",user.avatar)
    },
    //读取用户数据
    getUser() {
        let name = Cookie.get("Cookie-Name")
        let token = Cookie.get("Cookie-Token")
        let avatar = Cookie.get("Cookie-Avatar")
        //返回用户对象
        return {
            name,
            token,
            avatar
        }
    },
    //清空用户数据
    clear() {
        Cookie.remove("Cookie-Name")
        Cookie.remove("Cookie-Token")
        Cookie.remove("Cookie-Avatar")
    }
}